Learn R Programming

BLCOP (version 0.3.3)

Distribution class constructors: Constructors for distribution and mvdistribution class objects

Description

These functions create objects of class distribution and mvdistribution

Usage

mvdistribution(RName, ...)
distribution(RName, ...)

Arguments

RName

A string holding the R suffix corresponding to the distribution, e.g. "pois" for the Poisson distribution

Additional parameters that parametrize the distribution

Value

An object of class distribution or mvdistribution.

Details

In general any distribution with a corresponding sampling function can be used. This function should have the name given in RName but preceded with an "r", e.g. rnorm for the normal distribution. When the constructors are called, they check that the given sampling function exists and that it takes the arguments that were passed in the ....

See Also

sampleFrom

Examples

Run this code
# NOT RUN {
    
# }
# NOT RUN {
	    # create a uniform distribution object and sample from it
	    myUnif <- distribution("unif", min = -0.1, max = 0.1)
	    hist(sampleFrom(myUnif, 1000))
	    
	    mvNormal <- mvdistribution("mnorm", mean = c(1, 5), varcov = diag(c(2, 0.1)))
	    x <- sampleFrom(mvNormal, 1000)
	    plot(x[,1] ~ x[,2])
    
# }

Run the code above in your browser using DataLab